<?php

namespace app\store\controller\server;

use app\store\controller\Controller;
use app\store\model\server\Capital as CapitalModel;
use app\store\service\server\Export as Exportservice;


/**
 * 服务人员资金记录表
 * Class Setting
 * @package app\store\controller\apps\dealer
 */
class Capital extends Controller
{
    /**
     * 提现记录列表
     * @param int $user_id
     * @param int $apply_status
     * @param int $pay_type
     * @param string $search
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function index($user_id = null, $pay_type = -1, $search = '')
    {
        $model = new CapitalModel;
        return $this->fetch('index', [
            'list' => $model->getList($user_id, $pay_type, $search)
        ]);
    }


    /**
     * 订单导出
     * @param $dataType
     * @param $query
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function exportList($user_id = null, $pay_type = -1, $search = '')
    {
        $model = new CapitalModel;
        // 获取订单列表
        $list = $model->getList($user_id, $pay_type, $search);
        // 导出csv文件
        return (new Exportservice)->orderList($list);
    }
}